home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / PickOne / sources / PickOne_event.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  2.1 KB  |  107 lines  |  [TEXT/CWIE]

  1. /*  event.c                                                                            
  2.  
  3.     This contains all the code for routing and handling events.
  4.                                                                                     
  5.     Michael Bishop - August 21 1996                                                    
  6.     Nick Thompson
  7.     (c)1994-96 Apple computer Inc., All Rights Reserved                                
  8.  
  9. */
  10.  
  11. /* --------------------------------------------------------------------
  12. ** Includes
  13. */
  14.  
  15. #include    <Devices.h>
  16. #include    <QuickDraw.h>
  17.  
  18. /*  for QuickDraw 3D */
  19. #include    "QD3D.h"
  20. #include    "QD3DMath.h"
  21. #include    "QD3DDrawContext.h"
  22. #include    "QD3DShader.h"
  23. #include    "QD3DTransform.h"
  24. #include    "QD3DGroup.h"
  25.  
  26. #include    "PickOne_event.h"
  27. #include    "PickOne_document.h"
  28. #include    "PickOne_menu.h"
  29. #include    "PickOne_window.h"
  30. #include    "PickOne_main.h"
  31.  
  32.  
  33.  
  34. /*    --------------------------------------------------------------------
  35. **    Event_HandleKeyPress
  36. **    Handles a Key pressed
  37. */
  38. void Event_HandleKeyPress(EventRecord *theEvent)
  39. {
  40.     char    key;
  41.  
  42.     key = theEvent->message & charCodeMask;
  43.     
  44.     /*  just check to see if we want to quit... */
  45.     
  46.     if ( theEvent->modifiers & cmdKey ) {        /* Command key down? */
  47.         Menu_HandleCommand(MenuKey(key));
  48.     } 
  49.  
  50. }
  51.  
  52. /*    --------------------------------------------------------------------
  53. **    Event_DoOSEvent
  54. **    Handles an OSEvent
  55. */
  56. void    Event_DoOSEvent(EventRecord theEvent)
  57. {    char    mask;
  58.  
  59.     mask = (theEvent.message >> 24) && 0xFF;
  60.  
  61.     switch(mask) {
  62.         case mouseMovedMessage:
  63.             break;
  64.         case suspendResumeMessage:
  65.             Event_DoSuspendResume(theEvent);
  66.             break;
  67.     }
  68. }
  69.  
  70. /*    --------------------------------------------------------------------
  71. **    Event_DoSuspendResume
  72. **    Does nothing at the moment
  73. */
  74. void    Event_DoSuspendResume(EventRecord theEvent)
  75. {
  76.     if((theEvent.message & resumeFlag) != 0)
  77.     {
  78.         gForeground = true;
  79.         gTicks = 5;
  80.     }
  81.     else
  82.     {
  83.         gForeground = false;
  84.         gTicks = 50;
  85.     }
  86. }
  87.  
  88.  
  89. /*    --------------------------------------------------------------------
  90. **    Event_DoNull
  91. **    Do this when your app is idle
  92. */
  93. void Event_DoNull(void)
  94. {
  95.     /*  we received a null event, rotate the cube */
  96.     WindowPtr        theWindow;
  97.  
  98.     theWindow = FrontWindow() ;
  99.     
  100.     while( theWindow != NULL)
  101.     {
  102.         Document_Idle(Window_GetDocument( theWindow )) ;
  103.                     
  104.         theWindow = Window_GetNextWindow(theWindow);
  105.     }
  106. }
  107.